import { Button, Drawer, type ButtonProps, type DrawerProps } from 'antd';
import styles from './index.less';

interface CommonDrawerProps extends DrawerProps {
  onOk?: () => void;
  okText?: string;
  cancelText?: string;
  okBtnProps?: ButtonProps;
  cancelBtnProps?: ButtonProps;
}
const CommonDrawer = (props: CommonDrawerProps) => {
  const {
    onClose,
    onOk,
    okText = '确定',
    cancelText = '取消',
    okBtnProps,
    cancelBtnProps,
  } = props;

  return (
    <Drawer
      footer={
        <>
          <Button onClick={onClose} {...cancelBtnProps}>
            {cancelText}
          </Button>
          <Button type="primary" onClick={onOk} {...okBtnProps}>
            {okText}
          </Button>
        </>
      }
      maskClosable={false}
      {...props}
      onClose={onClose}
      classNames={{
        footer: styles.footer,
      }}
    />
  );
};
export default CommonDrawer;
